home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / PowerPC / vbcc / Examples / getinfo / getinfo.c next >
Encoding:
C/C++ Source or Header  |  1998-05-24  |  1.6 KB  |  72 lines

  1. /*
  2. ** getinfo.c
  3. **
  4. ** ANSI-C implementation of the WarpOS tool "showinfo".
  5. **
  6. ** V1.0  24-May-98  phx
  7. **       created
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <utility/tagitem.h>
  12. #include <powerpc/powerpc.h>
  13. #include <powerpc/tasksPPC.h>
  14. #include <clib/powerpc_protos.h>
  15.  
  16.  
  17. static char *cpu_names[] = {
  18.   "unknown","603","603e","604","604e","620"
  19. };
  20.  
  21. static char *cache1[2] = {
  22.   "on","off"
  23. };
  24.  
  25. static char *cache2[2] = {
  26.   "locked","unlocked"
  27. };
  28.  
  29.  
  30.  
  31. main()
  32. {
  33.   static ULONG tags[] = {
  34.     GETINFO_CPU,0,
  35.     GETINFO_PVR,0,
  36.     GETINFO_ICACHE,0,
  37.     GETINFO_DCACHE,0,
  38.     GETINFO_PAGETABLE,0,
  39.     GETINFO_TABLESIZE,0,
  40.     GETINFO_BUSCLOCK,0,
  41.     GETINFO_CPUCLOCK,0,
  42.     GETINFO_CPULOAD,0,
  43.     GETINFO_SYSTEMLOAD,0,
  44.     TAG_DONE
  45.   };
  46.   int cpu = 0;
  47.  
  48.   GetInfo((struct TagItem *)tags);
  49.  
  50.   /* print PowerPC infos */
  51.   if (tags[1] & CPUF_603) cpu = 1;
  52.   if (tags[1] & CPUF_603E) cpu = 2;
  53.   if (tags[1] & CPUF_604) cpu = 3;
  54.   if (tags[1] & CPUF_604E) cpu = 4;
  55.   if (tags[1] & CPUF_620) cpu = 5;
  56.  
  57.   printf("CPU:\t\t\tPowerPC %s  (PVR = %08lx)\n"
  58.          "CPU clock:\t\t%ld.%06ld MHz\n"
  59.          "Bus clock:\t\t%ld.%06ld MHz\n"
  60.          "Instruction cache:\t%s and %s\n"
  61.          "Data cache:\t\t%s and %s\n"
  62.          "Page table location:\t0x%08lx\n"
  63.          "Page table size:\t%ld KBytes\n"
  64.          "Cpu load:\t\t%ld.%02ld%%\n"
  65.          "System load:\t\t%ld.%02ld%%\n",
  66.          cpu_names[cpu],tags[3],
  67.          tags[15]/1000000,tags[15]%1000000,tags[13]/1000000,tags[13]%1000000,
  68.          cache1[(tags[5]&2)>>1],cache2[tags[5]&1],
  69.          cache1[(tags[7]&2)>>1],cache2[tags[7]&1],tags[9],tags[11],
  70.          tags[17]/100,tags[17]%100,tags[19]/100,tags[19]%100);
  71. }
  72.